<?php
//菜单卡管理
namespace app\siteadmin\model;

use think\Model;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class Menu extends Model{

    // 模型初始化
    protected static function init()
    {
        parent::init();
        //TODO:初始化内容
    }

        //菜单
    public function menuAll($where){
        $list = $this::name('menu')
        ->where($where)
        ->order('sort')
        ->select();
        return $list;
    }

    //菜单
    public function menulist($page,$num,$where){
        $list = $this::name('menu')
        ->where($where)
        ->limit(($page-1)*$num,$num)
        ->order('sort')
        ->select();
        return $list;
    }
    
    //菜单数量
    public function menuCount($where){
        $list = $this::name('menu')
        ->where($where)
        ->paginate();
        $count = $list->total();
        return $count;
    }
    
    //菜单添加
    public  function menuAdd(array $data){
        return self::create($data);
    }
    
    //菜单信息变更
    public function menuEdit($id,$update){
        $in = $this::update($update, ['id' => $id]);
        return $in;
    }
  
}
